﻿ 
@using Ext.Net
@using Ext.Net.MVC

@{
    var x = Html.X();
}

@(
 x.GridPanel()
            .TopBar(x.Toolbar().Items(
                x.Button().Text("浏览").OnClientClick("OnModuleOperation(this,'" + Url.Action("Details") + "');"),
                x.Button().Text("新增").OnClientClick("OnModuleOperation(this,'" + Url.Action("Create") + "',{ShowOnly:true});"),
                x.Button().Text("修改").OnClientClick("OnModuleOperation(this,'" + Url.Action("Edit") + "');"),
                x.Button().Text("删除").OnClientClick("OnModuleOperation(this,'" + Url.Action("Delete") + "',{IsAjax:true});"),
                x.Button().Text("权限").DirectClickAction("ListForUser", "Permission")
                    .DirectEvents(de =>
                    {
                        de.Click.ExtraParams.Add(new Parameter("owner", "user"));
                        de.Click.ExtraParams.Add(new Parameter("userName", "this.up('grid').getSelectionModel().selected.items[0].raw.UserName", ParameterMode.Raw));

                        de.Click.ExtraParams.Add(new Parameter("ownerId", "this.up('grid').getSelectionModel().selected.items[0].raw.Id", ParameterMode.Raw));
                    })
                ,
                new ToolbarFill(),
                x.TriggerField().Width(300).FieldLabel("搜索").LabelWidth(50)
                    .Triggers(
                        x.FieldTrigger().Icon(TriggerIcon.Clear).HideTrigger(true),
                        x.FieldTrigger().Icon(TriggerIcon.Search)
                    )
                    .Listeners(ls => { ls.TriggerClick.Fn = "searchFieldTriggerClick"; })
                ))
            .Store(x.StoreForModel()
                .Proxy(x.AjaxProxy().Url(Url.Action("GetPaged")).Reader(x.JsonReader().Root("data")))
                .RemoteSort(true).RemotePaging(true).PageSize(15)
                //.SorterFor(Model, m => m.Id, Ext.Net.SortDirection.ASC)
                )
            .SelectionModel(x.CheckboxSelectionModel())
 
            .ColumnModel(
                x.RowNumbererColumn().Align(Alignment.Right).Width(60)
               

            )
            .BottomBar(x.PagingToolbar().ItemsFromPartial("~/Areas/Manage/Views/Shared/_PagingToolbarPartial.cshtml"))
            .EmptyText("无数据。")
            .View(Html.X().GridView().StripeRows(true).TrackOver(true))
            .Listeners(li => { li.ItemDblClick.Fn = "OnModuleGridItemDblClick"; })
)